import java.io.File;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.LinkedBlockingDeque;



public class netz2135 {
 static List<Knoten> alleKnoten;
 static LinkedBlockingDeque<Mash> unstable =new LinkedBlockingDeque<Mash>();
 static MashCounter mashCounter = new MashCounter();
 
//// test main
// public static void main(String argv[]){
//  Graph gr= new Graph();  
//  xml2graph_parser p = new xml2graph_parser(gr, new CyclicBarrier(1)); //TODO argv.length));
//  File f = new File("..\\testsuite\\spice\\graph15.xml");
////  File f = new File("/home/govinda/uni/NP/projekt/testsuite/speed/graph19.xml");
////  File f = new File("/home/govinda/uni/NP/projekt/testsuite/crack/germany.xml");
////  boolean b = p.(gr);
//  
//  p.createGraph(f);
//  System.out.println("graph: " + gr);
////  System.err.println(gr);
//
//  alleKnoten = new CopyOnWriteArrayList<Knoten>(gr.getKnmap().values());
//  System.out.println("ini knoten: " + alleKnoten.size()); 
//
//  Maschen m = new Maschen( gr);
//  
////  Thread worker0 = new Thread(new Worker(unstable, m));
////  worker0.start();
////  try {
////   worker0.join();
////  } catch (InterruptedException e1) {
////  //egal
////  }
//  int many = 1;
//
//	Thread[] t = new Thread[many];
//
//	for(int i = 0; i < many; i++){
//		t[i] = new Thread(new Worker(unstable, m));
//		t[i].start();
//	}
//
//	for(int i = 0; i < many; i++){
//		try {
//			t[i].join();
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}
//	}
//  System.out.println("maschen: " + m);
//  System.out.println("Anzahl Stromnetze: " + m.getMaschen().size());
//  System.exit(m.getMaschen().size());
//
// } 

 
 
 
 public static void main(String[] args) {
	 String[] s = new String[]{"/home/govinda/uni/NP/projekt/testsuite/crack/germany.xml"};
	 main2(s);
	 
}
//test main
 public static void main2(String argv[]){
  Graph gr= new Graph();  
  xml2graph_parser p = new xml2graph_parser(gr, new CyclicBarrier(1)); //TODO argv.length));

  File f = new File(argv[0].toString());
  
  p.createGraph(f);


  alleKnoten = new CopyOnWriteArrayList<Knoten>(gr.getKnmap().values());

  Maschen m = new Maschen( gr);
  
  int many = 1;
  //
//  	Thread[] t = new Thread[many];
  //
//  	for(int i = 0; i < many; i++){
//  		t[i] = new Thread(new Worker(unstable, m));
//  		t[i].start();
//  	}
  //
//  	for(int i = 0; i < many; i++){
//  		try {
//  			t[i].join();
//  		} catch (InterruptedException e) {
//  			e.printStackTrace();
//  		}
//  	}
  System.out.println(mashCounter.getCount());
  System.exit(m.getMaschen().size());

 } 
 
 
 
////main fuer final mit args
//public static void main(String argv[]){
// Graph gr;
// xml2graph_parser p = new xml2graph_parser();
// File f = new File("/home/govinda/uni/NP/projekt/unser_bsp.xml");
// if(argv.length!=0){
// f = new File(argv[0].toString());
// gr = p.getGraph(f);
//
// Maschen m = new Maschen( gr);
// arbeit = m.getMaschen();
// Thread worker0 = new Thread(new Worker(arbeit, m));
// worker0.start();
// try {
//  worker0.join();
// } catch (InterruptedException e1) {
// //egal
// }
// System.out.println("Anzahl Stromnetze: " + m.maschen.size());
// System.exit(m.maschen.size());
//
//}
//else {
// System.exit(-1);
//}
//}
 
}